home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Debug Timer / DebugTimer.cp next >
Text File  |  2000-06-23  |  606b  |  48 lines

  1. // DebugTimer.cp
  2.  
  3. #ifndef DebugTimer_h
  4. #include "DebugTimer.h"
  5. #endif
  6. #ifndef __Timer__
  7. #include <Timer.h>
  8. #endif
  9. #ifndef DebugMessage_h
  10. #include "DebugMessage.h"
  11. #endif
  12.  
  13. #include <Events.h>
  14.  
  15. DebugTimer::DebugTimer()
  16.   : start( Now() ),
  17.      running( true )
  18.   {
  19.   }
  20.  
  21. uint32 DebugTimer::Now()
  22.   {
  23.     return TickCount();
  24.   }
  25.  
  26. void DebugTimer::Start()
  27.   {
  28.     running = true;
  29.     start = TickCount();
  30.   }
  31.  
  32. void DebugTimer::Stop()
  33.   {
  34.     uint32 time = Now() - start;
  35.     
  36.     DebugMessage message;
  37.     message << time << " ticks";
  38.     message.Show();
  39.  
  40.     running = false;
  41.   }
  42.  
  43. DebugTimer::~DebugTimer()
  44.   {
  45.     if ( running )
  46.         Stop();
  47.   }
  48.